public class StackPlot {

  int numOfCategories;
  int[] categoryColors;

  Integrator[][] freqPerCat;  // freqPerCat[ magCategory][ month]
 
  float freqMax;
  float freqMin;
  float targetFreqMax;
  float targetFreqMin;
  Integrator dynFreqMax;
  Integrator dynFreqMin;

  Date dateMax;
  Date dateMin;
  Date targetDateMax;
  Date targetDateMin;
  Integrator dynDateMax;
  Integrator dynDateMin;

  float plotX1, plotY1; //upper left
  float plotX2, plotY2; //lower right
  float lableX;

  PFont plotFont;
  String title;
  String xAxisTitle;
  String yAxisTitle;
  int titleSize;
  int axisTitleSize;
  int lableSize;
  boolean showAxisLabels;
  
  boolean targetingNewDates;
  boolean targetingNewFreqs;
  
  float majorInterval;
  float minorInterval;
  
  

 
  StackPlot(int[][] freqArray, Date dateMin, Date dateMax, float plotX1, float plotY1, float plotX2, float plotY2, String title,
             String xAxisTitle, String yAxisTitle, int[] categoryColors ) {
              
    //fill array of freq per cat
    freqPerCat = new Integrator[ freqArray.length ][ freqArray[0].length ];
    for(int i = 0; i < freqPerCat.length; i++){ //iterate through categories
        for( int j = 0; j < freqPerCat[i].length; j++ ){//iterate through months in a category
          freqPerCat[i][j] = new Integrator( (float) freqArray[i][j] );
        }
    }       
    
    this.dateMin = dateMin;
    this.dateMax = dateMax;
    this.plotX1 = plotX1;
    this.plotY1 = plotY1;
    this.plotX2 = plotX2;
    this.plotY2 = plotY2;  
    this.title = title;
    this.xAxisTitle = xAxisTitle;
    this.yAxisTitle = yAxisTitle;
    this.categoryColors = categoryColors;
    
    numOfCategories = freqPerCat.length;
    //find freqMax
    freqMax = getFreqMax(); 
    freqMin = 0;
    dynFreqMax = new Integrator( (float) freqMax );
    dynFreqMin = new Integrator( (float) freqMin );
    
    dynDateMax = new Integrator( dateMax.theYear + ((float) dateMax.theMonth)/12 );
    dynDateMin = new Integrator( dateMin.theYear + ((float) dateMin.theMonth)/12 );
    
    showAxisLabels = true;
  
    targetingNewDates = false;
    targetingNewFreqs = false;
  
  }
 
  void drawPlot() {
    
  }
  
  float getFreqMax(){
    float runningMax = 0; //will not have max freq of 0
    for( int month = 0; month < freqPerCat[0].length; month++ ){
      float freqCount = 0;
      for( int category = 0; category < freqPerCat.length; category++){
        freqCount += freqPerCat[category][month].value;
      }
      if( freqCount > runningMax ){
        runningMax = freqCount; 
      }
    }//end outer for loop
    return runningMax;   
  }//end method
  
 
}

